#ifndef _MY_WIFI_H
#define _MY_WIFI_H


#include "esp_wifi.h"
#include <stdlib.h>

#define EXAMPLE_ESP_MAXIMUM_RETRY  3

#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT      BIT1

#define CONN_OK 0
#define CONN_FAIL 1 
#define CONN_NONE 2
#define CONN_BOTH 3
#define CONN_ELTH 4

//wifi ssid pswd len  不能超过32和64
#define SSID_LEN 32
#define PSWD_LEN 64

//wifi nvs
#define SSID_KEY "wifi_ssid"
#define PSWD_KEY "wifi_pswd"
/*
char mywifi_ssid[32]   char=uint8_t
char mywifi_pswd[64]   char=uint8_t

开启wifi前需要初始化nvs，调用下面注释的代码开启nvs_flash
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);
*/

void modify_wificonfig_ssid(const char* pswd);
void modify_wificonfig_pswd(const char* pswd);

esp_err_t store_wificonfig_to_nvs(void);
esp_err_t set_wifi_config_from_nvs(void);




uint8_t wifi_init(void);
void start_sta_wifi(void);
uint8_t get_wifi_status(void);
void reset_wifi(void);
uint8_t app_wifi_wait_connected(void);




#endif